import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);

export default new Vuex.Store({
    state : {
        topIdList : [],
		nextId : '',
		// 歌曲播放实例
		innerAudioContext:null,
		// 播放中的歌曲名称
		name:'',
		// 播放或者暂停标识
		isPlay:'',
		// 当前播放音乐的总长度
		duration:0,
		// 当前播放音乐的播放位置
		currentTime:0,
		// 更新进度定时器标识
		scheduleTimer:null,
		// 歌词
		lrc:[],
		// 表示是歌曲加入歌单还是点击歌单查询歌单里面的歌曲 true表示点击歌单进入到歌单列表 false表示点击增加歌单
		isOriginalToSong:true,
		// 加入歌单的歌曲
		originalToSongList:[]
    },
    mutations : {
        INIT_CHANGE(state,payload){
            state.topIdList = payload;
        },
		INNERAUDIOCONTEXTEV(state,innerAudioContext){
			state.innerAudioContext = innerAudioContext
		},
		NAMEEV(state,name){
			state.name = name
		},
		ISPLAYEV(state,isPlay){
			state.isPlay = isPlay
		},
		DURATIONEV(state,duration){
			state.duration = duration
		},
		CURRENTTIMEEV(state,currentTime){
			state.currentTime = currentTime
		},
		SCHEDULETIMEREV(state,scheduleTimer){
			state.scheduleTimer = scheduleTimer
		},
		LRCEV(state,lrc){
			state.lrc = lrc
		},
		ISORIGINALTOSONGEV(state,isOriginalToSong) {
			state.isOriginalToSong = isOriginalToSong
		},
		RIGINALTOSONGLISTEV(state,originalToSongList) {
			state.originalToSongList = originalToSongList
		},
		NEXT_ID(state,payload){
			for(var i=0;i<state.topIdList.length;i++){
				if( state.topIdList[i].id == payload ){
					state.nextId = state.topIdList[i+1].id;
				}
			}
		}
    }
});